﻿/*
************************************************************
CreateDate  *  Author        *  Content
2008-08-01  *  Donne.Yang  *  Query data and execute data
************************************************************
NO   *  UpdateDate   *  Author        *  Content

*************************************************************
*/
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;


namespace Smg.Source
{
    public class StaticUtil
    {
        public StaticUtil()
        { 
        }

        /// <summary>
        /// 判断DataSet中是否存在数据
        /// </summary>
        /// <param name="dataSet">DataSet</param>
        /// <returns>bool</returns>
        public static bool IsDsHasData(DataSet dataSet)
        {
            bool blnResult = false;

            if (dataSet != null)
            {
                if (dataSet.Tables.Count > 0)
                {
                    if (dataSet.Tables[0].Rows.Count > 0)
                    {
                        blnResult = true;
                    }
                }
            }

            return blnResult;
        }
        
        /// <summary>
        /// 判断字符串是否符合该正则表达式
        /// </summary>
        /// <param name="strInput">预判断字符串</param>
        /// <param name="strPattern">正则表达式</param>
        /// <returns>bool</returns>
        public static bool RegularCheck(string strInput, string strPattern)
        {
            if (strInput.Equals("") || strPattern.Equals(""))
            {
                return false;
            }

            Regex rg = new Regex(strPattern);
            return rg.IsMatch(strInput);
        }

        public static int GetCharCountInString(string s,string c)
        {
            Regex regex = new Regex(c);
            MatchCollection ms = regex.Matches(s);
            return ms.Count;
        }
    }
}
